package com.william.jdbcplus.demo.config;

import com.alibaba.druid.pool.DruidDataSource;
import com.william.jdbcplus.boot.starter.constant.DataSourceConstant;
import com.william.jdbcplus.core.util.JdbcUtil;
import com.william.jdbcplus.demo.constant.DsConst;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author niliwei
 */
@Configuration
public class DruidConfig {
    @Value("${jdbc-plus.jdbc-url}")
    private String url;
    @Value("${jdbc-plus.jdbc-username}")
    private String username;
    @Value("${jdbc-plus.jdbc-password}")
    private String password;

    @Value("${jdbc-plus.jdbc-url1}")
    private String url1;
    @Value("${jdbc-plus.jdbc-username1}")
    private String username1;
    @Value("${jdbc-plus.jdbc-password1}")
    private String password1;

    @Bean(name = DataSourceConstant.MASTER)
    public DruidDataSource masterDataSourceBean() {
        DruidDataSource ds = JdbcUtil.createDataSource(url, username, password);
        return ds;
    }

    @Bean(name = DsConst.HIS)
    public DruidDataSource hisDataSourceBean() {
        DruidDataSource ds = JdbcUtil.createDataSource(url1, username1, password1);
        return ds;
    }
}